home *** CD-ROM | disk | FTP | other *** search
AMOS Source Code | 1992-09-28 | 3.7 KB | 129 lines |
- '***************************
- '* AMOS Professional *
- '* *
- '* MENUS 1 *
- '* * Creating and reading a simple menu
- '* (c) Europress Software *
- '* *
- '* Ronnie Simpson *
- '***************************
- '
- '-------------------------------------------
- 'SETTING UP
- '-------------------------------------------
- 'The initial stage in creating a menu is to set out the title headings:-
- '
- '
- ' Menu$(1)="SYSTEM "
- ' Menu$(2)="BRUSHES "
- ' Menu$(3)="COLOURS"
- '
- 'Titles are generated from left to right and spaces should be included in
- 'the strings to separate the titles along the bar.
- '
- 'The next thing we need is the options to be added:-
- '
- ' Menu$(1,1)="LOAD"
- ' Menu$(1,2)="SAVE"
- ' Menu$(1,3)="QUIT"
- ' Menu$(3,1)="RED"
- '
- 'Options are listed from top to bottom and there are no restrictions to the
- 'number of options each title can have.
- '
- 'When all your titles and options have been set out the menu must be switched
- 'on with the simple instruction:-
- '
- ' Menu On
- '
- 'Your set of titles will now appear each time the right mouse key is held
- 'down.
- '
- '-------------------------------------------
- 'READING A MENU
- '-------------------------------------------
- 'The simplest way of reading the menu is by use of the 3 versions of
- 'the =Choice function
- '-------
- '1) The first thing we need to know is whether the menu has been highlighted
- ' by the user, this is achieved by using =Choice without any parameters.
- ' A value of -1 (or True) will be returned if the menu is highlighted or
- ' a value of 0 (or False)will be returned if it is not.
- '
- ' If Choice=-1 Then Print "MENU ACTIVE"
- ' If Choice=-1 may be shortened to:- If choice then.....
- '
- '
- '2) To find the title that has been selected =Choice(1) is used:-
- '
- ' TITLE=Choice(1)
- '
- 'Choice(1) returns the index number of the title selected by the user.
- '
- '
- '3) And finally =Choice(2) is used to find the option selected.:-
- '
- ' OPTION=Choice(2)
- '
- 'Choice(2) returns the index number of the option selected by the user.
- '
- '-------------------------------------------
- 'WORKING EXAMPLE
- '-------------------------------------------
- '
- Rem *** tidy up the screen
- '
- Palette $0,$F00,$F0,$F,$FF0,$F0F,$FF,$F70,$7F,$70F,$F07,$333,$666,$999,$FFA,$FFF
- Flash Off : Curs Off : Cls 0 : Pen 0 : Paper 14 : Ink 4,0
- '
- Rem *** set the menu titles
- '
- Menu$(1)=" System "
- Menu$(2)=" Text Style "
- Menu$(3)=" Text Colours "
- '
- Rem *** set the options
- '
- Menu$(1,1)=" Edit "
- Menu$(1,2)=" Stop "
- Menu$(1,3)=" Quit "
- '
- Menu$(2,1)=" Normal "
- Menu$(2,2)=" Underline "
- Menu$(2,3)=" Bold "
- Menu$(2,4)=" Bold+underline "
- Menu$(2,5)=" Italic "
- Menu$(2,6)=" Italic +Underline "
- Menu$(2,7)=" Bold + Italic "
- Menu$(2,8)=" Bold + Italic + Underline "
- '
- Menu$(3,1)=" Red "
- Menu$(3,2)=" Green "
- Menu$(3,3)=" Blue "
- Menu$(3,4)=" Yellow "
- Menu$(3,5)=" Magenta "
- Menu$(3,6)=" Cyan "
- '
- Rem *** start the main loop and read the menu
- '
- Do
- Locate 0,20 : Cline : Centre "PRESS RIGHT MOUSE KEY TO SEE MENU"
- Repeat : Until Mouse Key=2
- Cline : Centre "MENU SYSTEM ACTIVATED"
- Menu On : T=0 : P=0
- Wait Vbl
- While Choice : Wend
- T=Choice(1)
- P=Choice(2)
- Menu Off
- If Choice(1)=2 Then Set Text P-1
- If Choice(1)=3 Then Ink P,0
- If Choice(1)=1 Then Edit
- If Not O Then Cls 0 : Text 66,100,"NO OPTION WAS SELECTED"
- If T
- Cls 0
- Text 50,40,"YOU SELECTED TITLE NUMBER"+Str$(T)
- Text 46,70,"YOU SELECTED OPTION NUMBER"+Str$(P)
- End If
- Loop
- Wait Key